package com.dimao.certificate_build_service.http;

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

public class SucceededReply extends Reply {
    private JsonObject result = null;
    private JsonArray results = null;
    private String resultStr = null;

    public SucceededReply(JsonObject result) {
        super(true);
        setResult(result);
    }

    public SucceededReply(JsonArray results){
        super(true);
        setResults(results);
    }

    public SucceededReply(String resultStr){
        super(true);
        setResultStr(resultStr);
    }

    public JsonObject toJson(){
        if(result != null) return super.toJson().put("data", result);
        else if(results != null) return super.toJson().put("data", results);
        else return super.toJson().put("data", resultStr);
    }

    public JsonObject getResult() {
        return result;
    }

    public void setResult(JsonObject result) {
        this.result = result;
    }

    public JsonArray getResults() {
        return results;
    }

    public void setResults(JsonArray results) {
        this.results = results;
    }

    public String getResultStr() {
        return resultStr;
    }

    public void setResultStr(String resultStr) {
        this.resultStr = resultStr;
    }
}
